---
title: IBM Db2
sidebarTitle: IBM Db2
---

This is the implementation of the IBM Db2 data handler for MindsDB.

[Db2](https://www.ibm.com/products/db2/database) is a database product from IBM. It is a Relational Database Management System (RDBMS). Db2 is designed to store, analyze, and retrieve the data efficiently. Db2 product is extended with the support of Object-Oriented features and non-relational structures with XML.

## Prerequisites

Before proceeding, ensure the following prerequisites are met:

1. Install MindsDB [locally via Docker](https://docs.mindsdb.com/setup/self-hosted/docker) or use [MindsDB Cloud](https://cloud.mindsdb.com/).
2. To connect IBM Db2 to MindsDB, install the required dependencies following [this instruction](/setup/self-hosted/docker#install-dependencies).
3. Install or ensure access to IBM Db2.

## Implementation

This handler is implemented using `ibm_db/ibm_db_dbi`, a Python library that allows you to use Python code to run SQL commands on the Db2 database.

The required arguments to establish a connection are as follows:

* `user` is the username associated with the database.
* `password` is the password required to authenticate your access to the database.
* `host` is the hostname or IP address of the server.
* `port` is the port through which TCP/IP connection is to be made.
* `database` is the database name to be connected.
* `schema` is required to get the tables.

## Usage

In order to make use of this handler and connect to the Db2 database in MindsDB, the following syntax can be used:

```sql
CREATE DATABASE DB2_datasource
WITH
    engine = 'DB2',
    parameters = {
        "user": "db2admin",
        "password": "1234",
        "host": "127.0.0.1",
        "port": 25000,
        "schema_name": "db2admin",
        "database": "BOOKS"
    };
```

You can use this established connection to query your table as follows:

```sql
SELECT *
FROM DB2_datasource.AUTHORS;
```
